package com.example.mybatisdemo1.extend;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Author: xiaoqiang
 * @Description:
 * @Date: 2020/9/11
 * @Version: 1.0
 */
public class PhoneValid implements ConstraintValidator<Iphone, String> {
    @Override
    public void initialize(Iphone constraint) {
    }

    /**
     * 验证是否有效
     *
     * @param obj
     * @param context
     * @return
     */

    @Override
    public boolean isValid(String obj, ConstraintValidatorContext context) {

        return obj.startsWith("173") ? true : false;
    }
}
